/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sqlserver;

import javax.swing.table.AbstractTableModel;

/**
 *
 * @author PHAMDANH
 */
public class MyTableModel extends AbstractTableModel {
    private Object[][] data;
    private String[] columnNames;
    public MyTableModel(Object[][] data, String[] colNames) {
        this.data = data;
        this.columnNames = colNames;
    }
    @Override
    public String getColumnName(int columnIndex) {
      return columnNames[columnIndex];
    }
    
    @Override
    public int getRowCount() {
        return data.length;
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return data[rowIndex][columnIndex];
    }


    @Override
    public Class getColumnClass(int col) {
        return data[0][col].getClass();
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        if(col==0)
            return false;
        if((Boolean)data[row][0]!=null)
            if(col==3&&(Boolean)data[row][0])
                return false;
        return true;
    }


    @Override
    public void setValueAt(Object value, int rowIndex, int columnIndex) {
        data[rowIndex][columnIndex] = value;
        fireTableCellUpdated(rowIndex, columnIndex);
    }
}
